﻿<UserControl x:Class="HBCode.Views.CustomersView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:converter="clr-namespace:HBCode.Converters"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:extended="clr-namespace:HBCode.ExtendedControls"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:wpfextended="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
             xmlns:wpftoolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
             x:Name="CustomerView"
             Background="{DynamicResource Office2010Background}"
             d:DesignHeight="300"
             d:DesignWidth="800"
             mc:Ignorable="d">
    <UserControl.Resources>
        <converter:WindowsStateConverter x:Key="windState" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <!--
            <Button Grid.Row="0"
            Width="80"
            Margin="5"
            HorizontalAlignment="Left"
            Command="{Binding DataContext.ViewCommand,
            ElementName=CustomerView}"
            CommandParameter="{Binding SelectedItem,
            ElementName=dgView}"
            Content="{DynamicResource View}" />
        -->

        <DataGrid x:Name="dgView"
                  Grid.Row="1"
                  AutoGenerateColumns="False"
                  Background="{DynamicResource Office2010Background}"
                  IsReadOnly="True"
                  ItemsSource="{Binding Customers}">
            <DataGrid.InputBindings>
                <KeyBinding Key="N"
                            Command="{Binding ElementName=dgView,
                                              Path=DataContext.AddNewCommand,
                                              IsAsync=True}"
                            Modifiers="Control" />
                <KeyBinding Key="F2"
                            Command="{Binding ElementName=dgView,
                                              Path=DataContext.ViewCommand,
                                              IsAsync=True}"
                            CommandParameter="{Binding ElementName=dgView,
                                                       Path=SelectedItem,
                                                       IsAsync=True}" />
                <MouseBinding Command="{Binding ElementName=dgView,
                                                Path=DataContext.ViewCommand,
                                                IsAsync=True}"
                              CommandParameter="{Binding ElementName=dgView,
                                                         Path=SelectedItem,
                                                         IsAsync=True}"
                              Gesture="LeftDoubleClick" />
                <!--
                    <KeyBinding Key="Delete"
                    Command="{Binding ElementName=dgView,
                    Path=DataContext.DeleteCommand,
                    IsAsync=True}"
                    CommandParameter="{Binding ElementName=dgView,
                    Path=SelectedItem,
                    IsAsync=True}" />
                -->
            </DataGrid.InputBindings>
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding CustomerName}" Header="{DynamicResource Customer.Name}" />
                <DataGridTextColumn Binding="{Binding Email}" Header="{DynamicResource Email}" />
            </DataGrid.Columns>
        </DataGrid>

        <!--
            <Popup IsOpen="{Binding DataContext.IsEditing, Mode=TwoWay, ElementName=CustomerView}" PopupAnimation="Fade" AllowsTransparency="True" Placement="Center" PlacementTarget="{Binding ElementName=CustomerView}" MinWidth="500" MinHeight="300">
            <Border BorderThickness="1" CornerRadius="4" BorderBrush="Black" Background="White" Padding="5">
        -->
        <wpfextended:ChildWindow Grid.Row="1"
                                 Width="600"
                                 Height="300"
                                 Background="{DynamicResource Office2010Background}"
                                 Caption="{DynamicResource CustomerDetails}"
                                 CloseButtonVisibility="Hidden"
                                 FontSize="16"
                                 Foreground="#FF001955"
                                 WindowStartupLocation="Center"
                                 WindowState="{Binding IsEditing,
                                                       Converter={StaticResource windState}}">
            <Grid Margin="20 0 0 0"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Top">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="20" />
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="1"
                           Grid.Column="0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           Text="{DynamicResource Customer.Name}" />

                <TextBox Grid.Row="1"
                         Grid.Column="1"
                         Width="200"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         FontSize="16"
                         Text="{Binding ActiveCustomer.CustomerName,
                                        ValidatesOnDataErrors=True}" />

                <!--<TextBlock Grid.Row="2"
                           Grid.Column="0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           Text="{DynamicResource Age}" />-->

                <!--
                    <TextBox Grid.Row="2"
                    Grid.Column="1"
                    Width="100"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Top"
                    FontSize="16"
                    Text="{Binding ActiveCustomer.Age,
                    ValidatesOnDataErrors=True}" />
                -->
                <!--<wpfextended:IntegerUpDown Grid.Row="2"
                                           Grid.Column="1"
                                           Width="100"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Top"
                                           FontSize="16"
                                           Minimum="18"
                                           Maximum="100"
                                           Value="{Binding ActiveCustomer.Age,
                                                          ValidatesOnDataErrors=True}" />-->

                <TextBlock Grid.Row="2"
                           Grid.Column="0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           Text="{DynamicResource DOB}" />

                <wpftoolkit:DatePicker Grid.Row="2"
                                       Grid.Column="1"
                                       Width="200"
                                       HorizontalAlignment="Left"
                                       VerticalAlignment="Top"
                                       FontSize="16"
                                       Text="{Binding ActiveCustomer.DOB,
                                                      Mode=TwoWay,
                                                      ValidatesOnDataErrors=True}" />

                <TextBlock Grid.Row="3"
                           Grid.Column="0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           Text="{DynamicResource Email}" />

                <TextBox Grid.Row="3"
                         Grid.Column="1"
                         Width="200"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         FontSize="16"
                         Text="{Binding ActiveCustomer.Email,
                                        ValidatesOnDataErrors=True}" />

                <TextBlock Grid.Row="4"
                           Grid.Column="0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"
                           Text="{DynamicResource Phone}" />

                <TextBox Grid.Row="4"
                         Grid.Column="1"
                         Width="200"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         FontSize="16"
                         Text="{Binding ActiveCustomer.Phone,
                                        ValidatesOnDataErrors=True}" />
            </Grid>
        </wpfextended:ChildWindow>
        <!--
            </Border>
            </Popup>
        -->
    </Grid>
</UserControl>
